import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class WidgetImage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
        appBar: new AppBar(title: new Text("Image的使用")),
        body: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Text("网络图片"),
              Image.network(
                "http://mdemo.kate4.com/uploads/games/202003/15846762426542.jpeg",
                fit: BoxFit.cover,
              ),
              Text("资源图片"),
              Image.asset(
                "assets/images/kate4.png",
                fit: BoxFit.scaleDown,
                height: 200,
                width: 200,
              ),
              Text("本地图片"),
              Image.file(
                File('/storage/emulated/0/DCIM/Camera/IMG_20200603_080504.jpg'),
                fit: BoxFit.scaleDown,
                height: 200,
                width: 200,
              ),
              Text("属性说明"),
              Image.network(
                "http://mdemo.kate4.com/uploads/games/202003/15846762426542.jpeg",
                fit: BoxFit.fitWidth,
                //缩放方式
                width: 300,
                height: 300,
                frameBuilder: (BuildContext context, Widget child, int frame,
                    bool wasSynchronouslyLoaded) {
                  //图片处理
                  return Padding(padding: EdgeInsets.all(100.0), child: child);
                },
                loadingBuilder:(BuildContext context, Widget child, ImageChunkEvent loadingProgress){
                  print("loadingBuilder:"+loadingProgress.toString());
                  return child;
                },
                //对齐方式
                alignment: Alignment.bottomCenter,
                //重复方式
                repeat: ImageRepeat.noRepeat,
              ),
            ],
          ),
        ));
  }
}
